﻿@using EmployeeLeaveSystem.Shared;
@using EmployeeLeaveSystem.Shared.Models;
@inject IMessageService _MessageService;
@inject HttpClient _HttpClient;
@inject ModalService _modalService;

<Table DataSource="listAddWorks" TItem="AddWork">
    <PropertyColumn Property="c=>c.Id" />
    <PropertyColumn Property="c=>c.Created" />
    <PropertyColumn Property="c=>c.StartTime" />
    <PropertyColumn Property="c=>c.EndTime" />
    <PropertyColumn Property="c=>c.workState" />
    <PropertyColumn Property="c=>c.AcceptFlag" />
    <ActionColumn>
        <Button OnClick="()=>{OpenModalMove(context.Id);}">查看</Button>
    </ActionColumn>
</Table>
@code {
    List<AddWork> listAddWorks = new();
    protected override async Task OnInitializedAsync() {
        listAddWorks = await _HttpClient.GetFromJsonAsync<List<AddWork>>($"api/Work/GetWorkInfos?usrId={GobalManager.myInfo?.Id}");
        _MessageService.Success("获取历史记录成功");
    }
    private async Task OpenModalMove(int Id) {
        var modalConfig = new ModalOptions {
                    Title = "详情",
                    Draggable = true,
                    Footer = null,
                    Maximizable = true,
                    Width = "80vw",
                    Content = @<ViewWorkManager Id="Id" />
        };

        await _modalService.CreateModalAsync(modalConfig);
    }
}
